<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>实战 - 生成女装数据</title>
</head>

<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.1-beta3/mock-min.js"></script>
    <h2>F12打开控制台查看数据，效果更佳</h2>
    <div class="box">
        展示内容:<div id="content"></div>
    </div>
    <script>
        // 定义数据类型
        let list = Mock.mock({
            // 20条数据
            "data|20": [{
                // 商品种类
                "goodsClass": "女装",
                // 商品Id
                "goodsId|+1": 1,
                //商品名称
                "goodsName": "@ctitle(10)",
                //商品地址
                "goodsAddress": "@county(true)",
                //商品等级评价★
                "goodsStar|1-5": "★",
                //商品图片
                "goodsImg": "@Image('100x100','@color','小甜甜')",
                //商品售价
                "goodsSale|30-500": 30

            }]
        })

        //展示数据
        console.table(list);
        x = document.getElementById("content");
        //将对象转为JSON
        x.innerHTML = JSON.stringify(list, null, '<br />');


    </script>

</body>

</html>